<!--
* description: 回收网点入库信息查询
* author: hzm
* createdDate: 2021-4-29
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-api-config="dynamicApiConfigs"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="false"
      :dynamic-is-init-table="true"
      :dynamic-is-fix-choose="false"
      :dynamic-is-fix-index="false"
    />
    <!-- 新增/详情 -->
    <edit
      :key="editPopupsKey"
      :dynamic-edit-row-data="editRowData"
      :popups-visible="editPopupsVisible"
      :popups-state="editPopupsState"
      @close="close"
    />
  </div>
</template>

<script>
import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
import OneTableTemplate from '@/components/templates/oneTable'
import { orgApis } from '@/api/caseManagementQuery'
import { exportExcel } from '@/utils/getTimeString.js'

export default {
  name: 'IncomingInformationQuery',
  components: {
    OneTableTemplate,
    Edit: () => import('./edit')
  },
  mixins: [oneTableWithViewTemplateMixins],
  data() {
    return {
      reclaimUnitCode: '',
      editRowData: {},
      editPopupsState: 'edit',
      editPopupsVisible: false,
      dynamicApiConfigs: orgApis.recoveryOutletsList,
      // 动态生成网格列
      tableCols:
        [
          {
            prop: 'controlBtn',
            label: '操作', // 操作
            codeField: 'controlBtn',
            width: 100,
            align: 'center',
            isComponent: true,
            comps: [
              {
                compKey: 'propKey1',
                labelName: '详情',
                align: 'center',
                component: () => import('@/components/org/linkButton'),
                clickEvent: (index) => this.edit(index)
              }
            ]
          },
          {
            prop: 'dlrCode',
            label: '门店编码',
            align: 'center'
          },
          {
            prop: 'dlrFullName',
            label: '门店名称',
            align: 'center'
          },
          {
            prop: 'batteryCode',
            label: '电池编码',
            align: 'center'
          },
          {
            prop: 'batterySpeciesName',
            label: '产品类型',
            align: 'center'
          },
          {
            prop: 'reclaimUnitName',
            label: '回收服务网点名称',
            align: 'center'
          },
          {
            prop: 'reclaimUnitCode',
            label: '回收服务网点统一社会信用代码',
            align: 'center'
          },
          {
            prop: 'putinDate',
            label: '入库日期',
            align: 'center'
          },
          {
            prop: 'creator',
            label: '登记人',
            align: 'center'
          }
        ],
      tableComponents:
          [
            // 库存状态
            {
              compKey: 'compKey1',
              labelName: '入库日期：',
              codeField: 'putinDateStart,putinDateEnd',
              component: () => import('@/components/org/datePicker/andtDatePicker'),
              type: 'YYYY-MM-DD',
              format: 'yyyy-MM-dd',
              dateOptionsType: '0',
              isMust: true,
              span: 6
            },
            // 车辆状态
            {
              compKey: 'compKey2',
              labelName: '门店编码：',
              codeField: 'dlrCode',
              component: () => import('@/components/ve/salesStore'),
              type: 'dropdownList',
              isMust: true,
              span: 6
            },
            // 入库仓库
            {
              compKey: 'compKey3',
              labelName: '回收服务网点名称：',
              codeField: 'reclaimUnitName',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              isMust: true,
              span: 6
            },
            {
              compKey: 'compKey5',
              labelName: '产品类型：',
              codeField: 'batterySpecies',
              customObj: {
                api: orgApis.productType,
                defOptionFields: ['LOOKUP_VALUE_CODE', 'LOOKUP_VALUE_NAME']
              },
              component: () => import('@/components/org/commonSelect'),
              type: 'dropdownList',
              isMust: true,
              span: 6
            }
          ],
      tableButtons: [
        {
          conmpKey: 'btenKey1',
          size: 'small',
          text: '新增',
          name: 'add',
          clickEvent: () => this.add(),
          position: 'left'
        },
        {
          conmpKey: 'btenKey2',
          size: 'small',
          clickEvent: () => this.export(),
          text: this.$t('sys.button.export'),
          name: 'export',
          position: 'left' // 导出
        },
        {
          conmpKey: 'btenKey3',
          type: 'primary',
          size: 'small',
          text: '查询',
          name: 'search',
          clickEvent: () => this.queryTable(1),
          position: 'right'
        },
        {
          conmpKey: 'btenKey4',
          size: 'small',
          text: '重置',
          name: 'reset',
          clickEvent: () => this.reset(),
          position: 'right'
        }
      ],
      formField: this.$utils.getFormField(this, {
        putinDateStart: '',
        putinDateEnd: '',
        dlrCode: '',
        reclaimUnitName: '',
        batterySpecies: ''
      })
    }
  },
  mounted() {
    this.queryTable(1)
  },
  methods: {
    export() {
      exportExcel(this.formField, orgApis.recoveryOutletsExcel.APIUrl, orgApis.recoveryOutletsExcel.ServiceCode, '回收网点入库信息查询')
    },
    close(type) {
      this.editPopupsVisible = type
    },
    // 详情
    edit(index) {
      this.editPopupsState = 'edit'
      this.editPopupsVisible = true
      this.editRowData = this.$refs['multipleTable'].list[index]
    },
    // 新增
    add() {
      this.editPopupsState = 'add'
      this.editPopupsVisible = true
    }
  }
}
</script>

<style>
</style>
